export default class SkuCountHandler {
    sqlite: any
    constructor(sqlite: any) {
        this.sqlite = sqlite
    }

    getHistoryList(releaseId: any, userId: any) {
        return new Promise((resolve, reject) => {
            this.sqlite.skuCount
                .getSkuList(releaseId, userId)
                .then((list: any) => {
                    resolve(list)
                })
                .catch(() => {
                    reject()
                })
        })
    }
    saveOrUpdate(list: any) {
        return new Promise((resolve, reject) => {
            this.sqlite.skuCount.saveOrUpdate(list)
            resolve('')
        })
    }
    delete(obj: any) {
        return new Promise((resolve, reject) => {
            this.sqlite.skuCount
                .delete({ whereObj: obj })
                .then(() => {
                    console.log('删除完成')
                    resolve('删除完成')
                })
                .catch(() => {
                    console.log('删除异常')
                    reject('删除异常')
                })
        })
    }
    /**
     * 置零 未选择的规格
     * @param {arr}  当前有数据的sku数组
     */
    clear(userId: any, releaseId: any, arr: Array<any>) {
        return new Promise((resolve, reject) => {
            this.sqlite.skuCount
                .clearSkuCountNotSelect(userId, releaseId, arr)
                .then(() => {
                    resolve('')
                })
                .catch(() => {
                    reject()
                })
        })
    }
}
